﻿namespace Sai.Core.Sandcastle
{
	using Sai.Core.Reporting;

	public class TopicCollectionBuilder
	{
		public Topic Build(ReportIndexCollection items)
		{
			Topic topLevel = null; 

			foreach (var index in items)
			{
				if (topLevel == null)
				{
					topLevel = new Topic(index.Guid, index.Title)
						{
							Path = index.Path
						};
				}
				else
				{
					topLevel.Add(new Topic(index.Guid, index.Title)
					{
						Path = index.Path
					});
				}
			}

			return topLevel;
		}
	}
}
